package com.example.controller;

import com.alibaba.fastjson.JSON;
import com.example.model.Book;
import com.example.service.BookService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * redis测试入口
 */
@RestController
public class RedisController {

	@Resource
	private BookService bookService;

	@PostMapping(value = "/testRedisHash",produces = "text/plain;charset=UTF-8")
	public String testRedisHash(){
		Book book = bookService.getBookByIdHash("123456");
		System.out.println("返回："+JSON.toJSONString(book));
		return JSON.toJSONString(book);
	}

	@PostMapping(value = "/testRedisStr",produces = "text/plain;charset=UTF-8")
	public String testRedisStr(){
		Book book = bookService.getBookByIdStr("123457");
		System.out.println("返回："+JSON.toJSONString(book));
		return JSON.toJSONString(book);
	}

}
